package com.waves.task.strategy.task;

import com.waves.core.frequencycontrol.enums.BusinessErrorEnum;
import com.waves.core.utils.AssertUtil;

import java.util.HashMap;
import java.util.Map;

/**
 * Description: 任务领取策略工厂
 * Author: dlw
 * Date: 2023-05-30
 */
public class TaskFactory {
    private static final Map<Integer, AbstractTaskStrategy> STRATEGY_MAP = new HashMap<>();

    public static void register(Integer markType, AbstractTaskStrategy strategy) {
        STRATEGY_MAP.put(markType, strategy);
    }

    public static AbstractTaskStrategy getStrategyNoNull(Integer type) {
        AbstractTaskStrategy strategy = STRATEGY_MAP.get(type);
        AssertUtil.isNotEmpty(strategy,BusinessErrorEnum.TASK_ERROR.getErrorMsg());
        return strategy;
    }
}
